package com.mybatisplus.mp.futuretask;

import javax.sound.midi.Soundbank;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class FutureDemo {
  static   ExecutorService pool = Executors.newFixedThreadPool(10);
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture<Integer> future1 = CompletableFuture.supplyAsync(() -> {
            return 1;
        }, pool);
        CompletableFuture<Integer> future2 = CompletableFuture.supplyAsync(() -> {
            return 2;
        }, pool);
        CompletableFuture<Integer> future3 = CompletableFuture.supplyAsync(() -> {
            return 3;
        }, pool);

        CompletableFuture<Void> future = CompletableFuture.allOf(future1, future2, future3);
        future.get();
    }
}
